<?php

	$path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
	$path_parts = pathinfo($path);
	$p = str_replace("wp-content","",$path_parts['dirname']);	
	$p = str_replace("themes","",$p);
	$p = str_replace("functions","",$p);
	$p = str_replace("shopperpress","",$p);
	$p = str_replace("\\\\","",$p);
	$p = str_replace("////","",$p);
			
	require( $p.'/wp-config.php' );

	if(is_numeric($_GET['link'])){
	
	$THISID = strip_tags($_GET['link']);
	
	$URL  	= get_post_meta($THISID, "amazon_link", true);
	if($URL ==""){
		$URL 			= get_post_meta($THISID, "link", true);
		if($URL ==""){			
			$URL 		= get_post_meta($THISID, "buy_link", true);
			if($URL ==""){			
				$URL 		= get_post_meta($THISID, "buy_url", true);
			}	
		}	
	
	} 
	
	$URL = ShopperAffiliateLink($URL);
 
?>

<html>
	<head>
		<title></title>
		<meta name="robots" content="noindex,nofollow" />
		<?php if(!empty($URL)) echo '<meta http-equiv="refresh" content="0; url='.$URL.'" />'; ?>
	</head>
	<body style="margin:0 auto;">
	 
	</body>
</html>

<?php } ?>